//
//  YXWithdrawalDetailTableView.m
//  CreditCard
//
//  Created by 杨旭 on 2017/12/23.
//  Copyright © 2017年 杨旭. All rights reserved.
//

#import "YXWithdrawalDetailTableView.h"

@interface YXWithdrawalDetailTableView ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic ,strong) UIView *headerView;
@property (nonatomic ,strong) UIView *footerView;
@property (nonatomic ,strong) UIButton *returnBtn;
@property (nonatomic ,strong) NSArray *titleArr;
@property (nonatomic ,strong) NSArray *contentArr;
@end

@implementation YXWithdrawalDetailTableView

- (NSArray *) titleArr {
    if (!_titleArr) {
        _titleArr = @[@"预计到账时间",@"提现金额"];
    }
    return _titleArr;
}


- (UIView *)headerView {
    if (!_headerView) {
        _headerView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, kScreenWidth, 180))];
        _headerView.backgroundColor = color_backColor;
        
        UIView *backView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, kScreenWidth, 150))];
        backView.backgroundColor = [UIColor whiteColor];
        [_headerView addSubview:backView];
        
        UIButton *btn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        btn.frame = CGRectMake((kScreenWidth - 80) / 2, 40, 80, 80);
        btn.titleLabel.font = [UIFont systemFontOfSize:14];
        [btn setImage:[UIImage imageNamed:@"提现_1"] forState:(UIControlStateNormal)];
        [btn setTitle:@"提现申请已提交" forState:(UIControlStateNormal)];
        [btn setTitleColor:color_textOne forState:(UIControlStateNormal)];
        [btn setImgViewStyle:(ButtonImgViewStyleTop) imageSize:(CGSizeMake(60, 60)) space:5];
        [backView addSubview:btn];
        
        UIView *lineView1 = [[UIView alloc] initWithFrame:(CGRectMake(0, _headerView.H - 31, kScreenWidth, 1))];
        lineView1.backgroundColor =color_lineColor;
        [_headerView addSubview:lineView1];
        UIView *lineView2 = [[UIView alloc] initWithFrame:(CGRectMake(0, _headerView.H - 1, kScreenWidth, 1))];
        lineView2.backgroundColor =color_lineColor;
        [_headerView addSubview:lineView2];
    }
    return _headerView;
}

- (UIButton *)returnBtn {
    if (!_returnBtn) {
        _returnBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _returnBtn.frame = CGRectMake(20, 100, kScreenWidth - 40, 50);
        _returnBtn.backgroundColor = color_globalColor;
        _returnBtn.layer.masksToBounds = YES;
        _returnBtn.layer.cornerRadius = 8.0f;
        [_returnBtn setTitle:@"返回" forState:(UIControlStateNormal)];
        [_returnBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
        [_returnBtn addTarget:self action:@selector(returnBtnAction) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _returnBtn;
}

- (void)returnBtnAction {
    if (self.pushRootView) {
        self.pushRootView();
    }
}

- (UIView *)footerView {
    if (!_footerView) {
        _footerView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, kScreenWidth, kScreenHeight-180 - self.titleArr.count * 44))];
        _footerView.backgroundColor = [UIColor whiteColor];
        [_footerView addSubview:self.returnBtn];
    }
    return _footerView;
}

- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
    if (self = [super initWithFrame:frame style:style]) {
        self.delegate = self;
        self.dataSource = self;
        self.tableHeaderView = self.headerView;
        self.tableFooterView = self.footerView;
    }
    return self;
}

#pragma mark - UITableView Delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.titleArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellID = @"YXWithdrawalDetailTableViewCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleValue1) reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.textLabel.text = self.titleArr[indexPath.row];
    if (indexPath.row == 0) {
        cell.detailTextLabel.text = @"24小时";
    }else {
        cell.detailTextLabel.text = self.price;
    }
    return cell;
}


@end
